package sy3;

public class BinaryOperationTester {
    public static void main(String[] args) {
        System.out.println("=== 开始测试 BinaryOperation 类 ===");
        
        // 测试1：构造方法
        System.out.println("测试1：构造方法");
        BinaryOperation op1 = new BinaryOperation();
        BinaryOperation op2 = new BinaryOperation(5, 3, '+');
        System.out.println("默认构造: " + op1);
        System.out.println("带参构造: " + op2);
        
        // 测试2：访问器方法
        System.out.println("\n测试2：访问器方法");
        System.out.println("左操作数: " + op2.getLeftOperand());
        System.out.println("右操作数: " + op2.getRightOperand());
        System.out.println("运算符: " + op2.getOperator());
        
        // 测试3：construct方法
        System.out.println("\n测试3：construct方法");
        op1.construct('+');
        System.out.println("构造加法: " + op1);
        op1.construct('-');
        System.out.println("构造减法: " + op1);
        
        // 测试4：生成方法
        System.out.println("\n测试4：生成方法");
        BinaryOperation op3 = new BinaryOperation();
        op3.generateAdditionOperation();
        System.out.println("生成加法: " + op3);
        op3.generateSubstractOperation();
        System.out.println("生成减法: " + op3);
        op3.generateBinaryOperation();
        System.out.println("生成混合: " + op3);
        
        // 测试5：equals方法
        System.out.println("\n测试5：equals方法");
        BinaryOperation op4 = new BinaryOperation(5, 3, '+');
        BinaryOperation op5 = new BinaryOperation(5, 3, '+');
        BinaryOperation op6 = new BinaryOperation(5, 4, '+');
        System.out.println("相同算式: " + op4.equals(op5));
        System.out.println("不同算式: " + op4.equals(op6));
        
        // 测试6：计算结果
        System.out.println("\n测试6：计算结果");
        System.out.println("5+3=" + op4.calculateResult());
        BinaryOperation op7 = new BinaryOperation(8, 3, '-');
        System.out.println("8-3=" + op7.calculateResult());
        
        System.out.println("\n=== BinaryOperation 类测试完成 ===");
    }
}